<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include("ListResult.php");
$arrFd = array(0 => "Name", 1 => "Account", 2 => "AddDate");
$arrOd = array(0 => "ASC", 1 => "DESC");
$intFd = ($_data["OrderField"] != "")?(int)$_data["OrderField"]:(int)$_SESSION[$SessionSQL."Fd"];
$intOd = ($_data["OrderBy"] != "")?(int)$_data["OrderBy"]:(int)$_SESSION[$SessionSQL."Od"];
if($intFd < 0 || $intFd > 2)$intFd = 2;
if($intOd < 0 || $intOd > 1)$intFd = 1;
$_SESSION[$SessionSQL."Fd"] = $intFd;
$_SESSION[$SessionSQL."Od"] = $intOd;
$strSQL = $strSQL." order by ".$arrFd[$intFd]." ".$arrOd[$intOd]." limit ".(($intPageNow-1)*$intPageNo).",".$intPageNo." ";
//print $strSQL;

if(!$RS = mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = $_strOperator["ErrMessage"];//"系統發生錯誤, 請連絡工程師！";
	$GLOBALS["errorhidden"] = "\n Error: ".mysql_error($$_Conn).",\nSQL: ".$strSQL.",\nLine: ".__LINE__.",\nPage: ".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}

$fp = @file($strTemplatePath."List.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

while(list($k, $v) = each($_strOperator)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

$strCon = "";
//分頁下拉清單
for($i = 1; $i <= $intTotalPage; $i++){
	if($i == $intPageNow){
		$strCon .= "<option value='".$i."' selected>".$i."</option>\n";
	}else{
		$strCon .= "<option value='".$i."'>".$i."</option>\n";
	}
}
$fp = str_replace("{PageSelectOpion}", $strCon, $fp);
$fp = str_replace("{intTotalPage}", $intTotalPage, $fp);
$fp = str_replace("{intPageNow}", $intPageNow, $fp);
$fp = str_replace("{intTotal}", $intTotal, $fp);
$fp = str_replace("{Locked".$_data["isLock"]."}", "selected", $fp);
$fp = str_replace("{OrderField}", $intFd, $fp);
$fp = str_replace("{OrderField".$intFd."}", "selected", $fp);
$fp = str_replace("{OrderBy}", $intOd, $fp);
$fp = str_replace("{OrderBy".$intOd."}", "selected", $fp);
$fp = str_replace("{ShowisLock}", $_data["isLock"], $fp);

//內容清單
$strCon = "";
$strTmp = "";
preg_match("/<!-- @ Content Start @ \/\/-->(.+)<!-- @ Content End @ \/\/-->/s", $fp, $arrCon);
while($Rows = mysql_fetch_object($RS)){
	$strGroup = GetRelationType2 ("bet_MemberGroup", $Rows -> MemberGroup, "ID, GroupName_".$_intLang." as Value");
	$strAddDate = DateForm($Rows -> AddDate, $Rows -> AddTime, "y-m-d")."&nbsp;".TimeForm($Rows -> AddDate, $Rows -> AddTime, "h:i");
	switch($Rows -> isLock){
		case "0":
			$strLock = $_strOperator["OnUnLocked"];
			break;
		case "1":
			$strLock = "<a style=\"color:#FFFFFF; background-color:#000000\">&nbsp;&nbsp;&nbsp;&nbsp;".$_strOperator["OnLocked"]."&nbsp;&nbsp;&nbsp;&nbsp;</a>";
			break;
	}
	$strTmp = str_replace("{ShowName}", $Rows -> Name, $arrCon[1]);
	$strTmp = str_replace("{ShowAccount}", $Rows -> Account, $strTmp);
	$strTmp = str_replace("{ShowAddDate}", $strAddDate, $strTmp);
	$strTmp = str_replace("{ShowGroup}", $strGroup, $strTmp);
	$strTmp = str_replace("{ShowID}", $Rows -> ID, $strTmp);
	$strTmp = str_replace("{ShowLock}", $strLock, $strTmp);
	if($Rows -> isLock == '1'){
		$strLock = "<a href=\"JavaScript:Lock(".$Rows -> ID.",0)\">".$_strOperator["UnLocked"]."</a>";
	}else{
		$strLock = "<a href=\"JavaScript:Lock(".$Rows -> ID.",1)\">".$_strOperator["Locked"]."</a>";
	}
	$strTmp = str_replace("{isLock_Link}", $strLock, $strTmp);

	$strCon .= $strTmp."\n";
}
$fp = preg_replace("/<!-- @ Content Start @ \/\/-->.+<!-- @ Content End @ \/\/-->/s", $strCon, $fp);

//輸出
WebOutputHTML($fp, 1);
?>